﻿package idv.cjcat.monica.platformer.player {
	import flash.display.MovieClip;
	import idv.cjcat.monica.Ref;
	import idv.cjcat.rusher.geom.Vec2D;
	
	internal class PlayerState {
		
		protected var controller:PlayerController;
		protected var direction:Number;
		
		public function PlayerState(controller:PlayerController, direction:Number) {
			this.controller = controller;
			this.direction = direction;
		}
		
		protected function get renderTarget():PlayerRenderTarget { return controller.renderTarget; }
		
		protected function setPlayerMovieClip(clip:MovieClip, resetDirection:Boolean):void {
			controller.setPlayerMovieClip(clip);
			if (resetDirection) updateRenderTargetDirection();
		}
		
		protected function updateRenderTargetDirection():void {
			renderTarget.direction = controller.direction;
		}
		
		public function setState(State:Class):void {
			controller.state = new State(controller, controller.direction);
		}
		
		protected function getVelocity():Vec2D { return controller.entity.getProperty(Ref.VELOCITY); }
		protected function setVelocity(value:Vec2D):void {
			controller.entity.setProperty(Ref.VELOCITY, value);
		}
		
		public function startJump():void {
			
		}
		
		public function stopJump():void {
			
		}
			
		public function onTick(time:Number):void {
			
		}
	}
}